package testing;

public class Notifier {

	private static final int SMALL_DEFAULT = 20;

	private static final int LARGE_DEFAULT = 4;

	private int length;

	private String endMessage;

	private int frequencySmall;

	private int frequencyLarge;

	private final char smallChar = '#';

	private final char largeChar = '!';

	private double ratioSmall;

	private double ratioLarge;

	private int count;

	public Notifier(int length, String startMessage, String endMessage) {
		this(length, startMessage, endMessage, SMALL_DEFAULT, LARGE_DEFAULT);
	}

	public Notifier(int length, String startMessage, String endMessage,
			int frequencySmall, int frequencyLarge) {
		this.length = length;
		this.endMessage = endMessage;
		this.frequencyLarge = frequencyLarge;
		this.frequencySmall = frequencySmall;

		ratioSmall = length / this.frequencySmall;
		ratioLarge = length / this.frequencyLarge;
		reset();
		System.out.print(startMessage);
	}

	public void next() {
		count++;
		if (count % ratioSmall < 1) {
			System.out.print(smallChar);
		}

		if (length - count < 1 && length - count >= 0) {
			System.out.println(endMessage);
		} else if (count % ratioLarge < 1) {
			System.out.print(largeChar);
		}

	}

	public void reset() {
		count = 0;
	}

	public static void main(String arg[]) {
		int length = 301;
		Notifier n = new Notifier(length, "Start: [", "]");
		for (int i = 0; i < length; i++) {
			n.next();
		}
		System.out.println("Finish");
	}
}
